package com.sphd.emanu.fragment.topuptodayorder;


import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.RecyclerView;

import com.sphd.emanu.R;
import com.sphd.emanu.adapter.TopUpTodaydapter;

import com.sphd.emanu.interfaces.TopuptodayorderFragmentLetter;
import com.sphd.emanu.mvp.MVPBaseFragment;
import com.sphd.emanu.pojo.vip.MemDeposit;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

// TODO: 2017/4/24 充值订单

/**
 * @Author Hu
 * @Time 2017/4/24 -- 16:10.
 * @Email 87683202@qq.com
 */
public class TopuptodayorderFragment extends MVPBaseFragment<TopuptodayorderContract.View, TopuptodayorderPresenter> implements TopuptodayorderContract.View {

    @BindView(R.id.my_recycler)
    RecyclerView myRecycler;
    @BindView(R.id.my_swf)
    SwipeRefreshLayout mySwf;
    Unbinder unbinder;
    TopUpTodaydapter topUpTodaydapter;
    TopuptodayorderFragmentLetter topuptodayorderFragmentLetter;

    public void setTopuptodayorderFragmentLetter(TopuptodayorderFragmentLetter topuptodayorderFragmentLetter) {
        this.topuptodayorderFragmentLetter = topuptodayorderFragmentLetter;
    }

    @Override
    protected int getLayoutId() {
        return R.layout.myswf_and_recycler;
    }

    @Override
    protected void initView() {
        unbinder = ButterKnife.bind(this, rootView);
        initAdapter();
        topuptodayorderFragmentLetter.readyedTopUpToday();
        setUserVisibleHint(true);
        initEvent();
    }

    private void initEvent() {
        mySwf.setOnRefreshListener(()->mySwf.setRefreshing(false));
    }

    private void initAdapter() {
        setRefresh(mySwf);
        setRecyWithDecoration(myRecycler);
        topUpTodaydapter = new TopUpTodaydapter(R.layout.item_topup_today_order, new ArrayList<MemDeposit>(), context);
        if (null != topUpTodaydapter.getEmptyView()) {
            topUpTodaydapter.setEmptyView(emptyView);
        }
        myRecycler.setAdapter(topUpTodaydapter);
    }

    @Override
    protected void initData() {

    }

    public void setList(List<MemDeposit> memDepositList) {
        topUpTodaydapter.setNewData(memDepositList);
    }
}
